package com.jmeurope.dao.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.jmeurope.dao.IbatisBaseDao;
import com.jmeurope.dao.UserDao;
import com.jmeurope.model.User;
/**
 * 
 * Description: 
 *
 * @author 王威    Email:leo_java@163.com
 * @version 1.0
 * History: 
 *
 * Date                     Author         Version     Description
 * ---------------------------------------------------------------------------------
 * Aug 18, 2011 10:46:59 PM         王威     3.0         To create
 *
 * @since 
 * @see
 */
@Repository
public class UserDaoImpl extends IbatisBaseDao implements UserDao{

	
    @Override
	public Integer insert(User user) throws SQLException {
    	return (Integer)getSqlMapClientTemplate().insert("insertUser", user);
    }

	@Override
	public void delete(Integer id) throws SQLException {
		getSqlMapClientTemplate().getSqlMapClient().delete("deleteUserById", id);
	}

	@Override
	public User find(Integer id) throws SQLException {
		return (User)getSqlMapClientTemplate().getSqlMapClient().queryForObject("getUserByUserId",id);
	}

	@Override
	public void update(User entity) {
		// TODO Auto-generated method stub
		
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<User> findAll() throws SQLException {
	    List<User>	users = getSqlMapClientTemplate().getSqlMapClient().queryForList("getALLUsers");
		return users;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<User> findByConditions(Map conditions) throws SQLException {
		List<User>	users = getSqlMapClientTemplate().getSqlMapClient().queryForList("getUsersByCondition",conditions);
		return users;
	}
}
